package com.edgclub.edg.utils.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import java.util.HashSet;
import java.util.Set;

/**
 * 偏好控制类
 * 
 */
public class OptionPrefUtil {
	private static final String PREFERENCES_NAME = "gz_option_pref";
	public static final String KEY_ViIBRATE = "vibrate";// 震动
	public static final String KEY_SOUND = "sound";// 声音
	public static final String KEY_MODEL = "model";// 听筒模式
	public static final String KEY_SEARCH = "search";// 是否可以被搜索
	private static OptionPrefUtil instance;
	public static final String KEY_BBUPDATE = "bbupdate";// 是否可以被搜索
	
	private static final String KEY_GROUP_MESSAGE="groupimid"; //群消息提醒

	private Context mContext;

	private SharedPreferences sharedPreferences;
	private Editor editor;

	private OptionPrefUtil(Context mContext) {
		this.mContext = mContext;
		sharedPreferences = mContext.getSharedPreferences(PREFERENCES_NAME,
				Context.MODE_PRIVATE);
		editor = sharedPreferences.edit();
	}

	public static OptionPrefUtil getInstance(Context mContext) {
		if (null == instance) {
			instance = new OptionPrefUtil(mContext);
		}
		return instance;
	}
	/**
	 * 设置BB更新
	 *
	 * @param context
	 * @param bbupdate
	 */
	public void setBbupdate(boolean bbupdate) {
		editor.putBoolean(KEY_BBUPDATE, bbupdate);
		editor.commit();
	}
	/**
	 * 是否BB更新
	 *
	 * @param context
	 * @return
	 */
	public boolean getBbupdate() {
		return sharedPreferences.getBoolean(KEY_BBUPDATE, true);
	}
	/**
	 * 是否震动
	 * 
	 * @param context
	 * @return
	 */
	public boolean getVibrate() {
		return sharedPreferences.getBoolean(KEY_ViIBRATE, true);
	}

	/**
	 * 设置震动
	 * 
	 * @param context
	 * @param vibrate
	 */
	public void setVibrate(boolean vibrate) {
		editor.putBoolean(KEY_ViIBRATE, vibrate);
		editor.commit();
	}

	/**
	 * 设置声音
	 * 
	 * @param sound
	 */
	public void setSound(boolean sound) {
		editor.putBoolean(KEY_SOUND, sound);
		editor.commit();
	}

	/**
	 * 获取声音设置
	 * 
	 * @return
	 */
	public boolean getSound() {
		return sharedPreferences.getBoolean(KEY_SOUND, true);
	}

	/**
	 * 听筒模式
	 * 
	 * @return
	 */
	public boolean getModel() {
		return sharedPreferences.getBoolean(KEY_MODEL, false);
	}

	/**
	 * 设置听筒模式
	 * 
	 * @param model
	 */
	public void setModel(boolean model) {
		editor.putBoolean(KEY_MODEL, model);
		editor.commit();
	}

	/**
	 * 搜索模式
	 * 
	 * @return
	 */
	public boolean getSearch() {
		return sharedPreferences.getBoolean(KEY_SEARCH, true);
	}

	/**
	 * 设置搜索模式
	 * 
	 * @param sound
	 */
	public void setSearch(boolean sound) {
		editor.putBoolean(KEY_SEARCH, sound);
		editor.commit();
	}
	
	
	/**
	 * 获取不用提醒的群imgid
	 * 
	 * @return
	 */
	public Set<String> getUnRemindImgids() {
		return sharedPreferences.getStringSet(KEY_GROUP_MESSAGE, new HashSet<String>());
//		return sharedPreferences.getString(KEY_GROUP_MESSAGE, "");
	}

	/**
	 * 设置不用提醒群消息的群imgid
	 * 
	 * @param sound
	 */
	public void setUnRemindImdids( Set<String> values) {
//		editor.putString(KEY_GROUP_MESSAGE, gnos);
		editor.putStringSet(KEY_GROUP_MESSAGE, values);
		editor.commit();
	}


}
